package com.epfresh.supplier.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.epfresh.api.utils.MarketPermissionUtil;
import com.epfresh.supplier.Listener.IndexIconOnClickListener;
import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.HomePart;
import com.epfresh.supplier.widget.CommonRecyclerAdapter;
import com.epfresh.supplier.widget.ViewHolder;

import java.util.List;

public class HomePartTopAdapter extends CommonRecyclerAdapter<HomePart> {
    private IndexIconOnClickListener indexIconOnClickListener;
    private boolean isShowRedPoint = false;

    public HomePartTopAdapter(Context context, List<HomePart> datas) {
        super(context, datas, R.layout.index_top_item);
    }

    public void setShowRedPoint(boolean isShowRedPoint) {
        this.isShowRedPoint = isShowRedPoint;
    }

    public void setListener(IndexIconOnClickListener indexIconOnClickListener) {
        this.indexIconOnClickListener = indexIconOnClickListener;
    }

    public void setDatas(List<HomePart> datas){
        super.setData(datas);
    }

    @Override
    public void convert(ViewHolder holder, final HomePart item, int position) {
        ImageView pic = holder.getView(R.id.iv_pic);
        ImageView ivPoint = holder.getView(R.id.iv_point);
        RelativeLayout rlIcon = holder.getView(R.id.rl_icon);
        switch (item.getName()) {
            case MarketPermissionUtil.marketOis:
                pic.setBackgroundResource(R.mipmap.entry_registration_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "进场登记");
                break;
            case MarketPermissionUtil.marketDetection:
                pic.setBackgroundResource(R.mipmap.presentation_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "检测报告");
                break;
            case MarketPermissionUtil.marketMyDetection:
                pic.setBackgroundResource(R.mipmap.mycontract_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "我的合同");
                break;
            case MarketPermissionUtil.marketMyCar:
                pic.setBackgroundResource(R.mipmap.mycar_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "我的车辆");
                break;
            case MarketPermissionUtil.marketPreRegistration:
                pic.setBackgroundResource(R.mipmap.register_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "预登记");
                break;
            case MarketPermissionUtil.marketPay:
                pic.setBackgroundResource(R.mipmap.pay_white);
                holder.setText(R.id.tv_name, "缴费");
                if (isShowRedPoint) {
                    ivPoint.setVisibility(View.VISIBLE);
                } else {
                    ivPoint.setVisibility(View.GONE);
                }
                break;
            case MarketPermissionUtil.appSupplierOrder:
                pic.setBackgroundResource(R.mipmap.order_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "销售订单");
                break;
            case MarketPermissionUtil.appSupplierProductSelling:
                pic.setBackgroundResource(R.mipmap.spot_commodity_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "现货商品");
                break;
            case MarketPermissionUtil.appSupplierIncome:
                pic.setBackgroundResource(R.mipmap.my_income_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "我的收入");
                break;
            case MarketPermissionUtil.appSupplierProductStanding_book:
                pic.setBackgroundResource(R.mipmap.my_ledger_white);
                ivPoint.setVisibility(View.GONE);
                break;
            case MarketPermissionUtil.appSupplierOrderJmt:
                pic.setBackgroundResource(R.mipmap.waiver_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "减免退");
                break;
            case MarketPermissionUtil.appSupplierEmployee:
                pic.setBackgroundResource(R.mipmap.staff_management_white);
                holder.setText(R.id.tv_name, "员工管理");
                ivPoint.setVisibility(View.GONE);
                break;
            case MarketPermissionUtil.appSupplierProductPurchase:
                pic.setBackgroundResource(R.mipmap.stock_management_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "进货管理");
                break;
            case MarketPermissionUtil.appSupplierCustomer:
                pic.setBackgroundResource(R.mipmap.customer_management_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "客户管理");
                break;
            case MarketPermissionUtil.appSupplierProductPrice:
                pic.setBackgroundResource(R.mipmap.changemoney_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "变价");
                break;
            case MarketPermissionUtil.appSupplierToIncome:
                pic.setBackgroundResource(R.mipmap.collection_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "收款");
                break;
            case MarketPermissionUtil.appSupplierStore:
                pic.setBackgroundResource(R.mipmap.my_stores_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "我的店铺");
                break;
            case MarketPermissionUtil.appSupplierProductPresell:
                pic.setBackgroundResource(R.mipmap.pre_sale_goods_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "预售商品");
                break;
            case MarketPermissionUtil.appSupplierJointOrder:
                pic.setBackgroundResource(R.mipmap.stock_up_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "备货");
                break;
            case MarketPermissionUtil.appSupplierProductOften_order:
                pic.setBackgroundResource(R.mipmap.grab_sheet_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "抢单");
                break;
            case MarketPermissionUtil.appSupplierComment:
                pic.setBackgroundResource(R.mipmap.evaluate_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "评价");
                break;
            case MarketPermissionUtil.appSupplierCoupon:
                pic.setBackgroundResource(R.mipmap.coupon_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "优惠券");
                break;
            case MarketPermissionUtil.appSupplierJointProduct:
                pic.setBackgroundResource(R.mipmap.offer_white);
                ivPoint.setVisibility(View.GONE);
                holder.setText(R.id.tv_name, "联营报价");
                break;
        }
        rlIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (indexIconOnClickListener != null) indexIconOnClickListener.onclick(item.getName());
            }
        });

    }
}
